package com.woniuxy.test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @author: ideaAdmin
 * TODO:
 * Date: 2022/1/21:10:03
 * Description:
 */

public class ArrayCopy {
    public static void main(String[] args) {
        int[] elementData = {1,2,3,4,5};

        //向下标3的位置插入新的数据
        elementData = Arrays.copyOf(elementData,elementData.length+1);
        int index = 3;

        System.arraycopy(elementData,index,elementData,index+1,5-index);

        elementData[index] = 6;
        System.out.println(Arrays.toString(elementData));

        List<Integer> integers = new ArrayList<>(Arrays.asList(1, 2, 3, 4, 5));
        integers.add(0,10);
        integers.forEach(System.out::println);
    }
}
